# -*- coding: UTF-8 -*-
from django.db import models
from django.contrib.auth.models import User
from django import forms
from django.db import models

# Create your models here.
# Opisuje wszystkie możliwe do użycia przełączniki.
# Na podstawie tych wartości generowanych jest widok
# dla użytkownika (true/false - pokaż/ukryj).
class NcPermissionForOption(models.Model):
    # Bind permission to the user
    user = models.ForeignKey(User)
    IPv4Option = models.BooleanField(default=1, verbose_name="-IPv4")
    IPv6Option = models.BooleanField(default=1, verbose_name="-IPv6")
    D_Option = models.BooleanField(default=1, verbose_name="-D")
    dOption = models.BooleanField(default=1, verbose_name="-d")
    hOption = models.BooleanField(default=1, verbose_name="-h")
    kOption = models.BooleanField(default=1, verbose_name="-k")
    lOption = models.BooleanField(default=1, verbose_name="-l")
    nOption = models.BooleanField(default=1, verbose_name="-n")
    rOption = models.BooleanField(default=1, verbose_name="-r")
    S_Option = models.BooleanField(default=1, verbose_name="-S")
    tOption = models.BooleanField(default=1, verbose_name="-t")
    U_Option = models.BooleanField(default=1, verbose_name="-U")
    uOption = models.BooleanField(default=1, verbose_name="-u")
    vOption = models.BooleanField(default=1, verbose_name="-v")
    zOption = models.BooleanField(default=1, verbose_name="-z")

# Opisuje wszystkie możliwe do użycia parametry.
# Na podstawie tych wartości generowanych jest widok
# dla użytkownika (true/false - pokaż/ukryj).
class NcPermissionForParameter(models.Model):
    # Bind permission to the user
    user = models.ForeignKey(User)
    iOption = models.BooleanField(default=1, verbose_name="-i interval")
    P_Option = models.BooleanField(default=1, verbose_name="-P proxy_username")
    pOption = models.BooleanField(default=1, verbose_name="-p source_port")
    sOption = models.BooleanField(default=1, verbose_name="-s source_ip_address")
    T_Option = models.BooleanField(default=1, verbose_name="-T ToS")
    wOption = models.BooleanField(default=1, verbose_name="-w timeout")
    X_Option = models.BooleanField(default=1, verbose_name="-X proxy_protocol")
    xOption = models.BooleanField(default=1, verbose_name="-x proxy_address")

# Opisuje formularz, jaki zostanie wygenerowany dla parametrów polecenia.
# Definiuje walidację danego pola, jego etykietę oraz tekst podpowiedzi.
class NcFormForParameters(forms.Form):
    iOption = forms.CharField(
        max_length=128,
        required = False,
        label = '-i',
        help_text = 'interval')
    P_Option = forms.CharField(
        max_length=128,
        required = False,
        label = '-P',
        help_text = 'proxy_username')
    pOption = forms.CharField(
        max_length=128,
        required = False,
        label = '-p',
        help_text = 'source_port')
    sOption = forms.CharField(
        max_length=128,
        required = False,
        label = '-s',
        help_text = 'source_ip_address')
    T_Option = forms.CharField(
        max_length=128,
        required = False,
        label = '-T',
        help_text = 'ToS')
    wOption = forms.CharField(
        max_length=128,
        required = False,
        label = '-w',
        help_text = 'timeout')
    X_Option = forms.CharField(
        max_length=128,
        required = False,
        label = '-X',
        help_text = 'proxy_protocol')
    xOption = forms.CharField(
        max_length=128,
        required = False,
        label = '-x',
        help_text = 'proxy_address')

# Opisuje formularz, jaki zostanie wygenerowany dla parametrów polecenia.
# Definiuje walidację danego pola, jego etykietę oraz tekst podpowiedzi.
class HostForm(forms.Form):
    host = forms.CharField(
        max_length = 128,
        required = False,
        help_text = 'host',)

# Opisuje formularz, jaki zostanie wygenerowany dla opcji polecenia.
# Definiuje walidację danego pola, jego etykietę oraz tekst podpowiedzi.
class NcFormForOptions(forms.Form):
    IPv4Option = forms.BooleanField(
        required = False,
        label = '-4',
        help_text = 'Forces nc to use IPv4 addresses only.')
    IPv6Option = forms.BooleanField(
        required = False,
        label = '-6',
        help_text = 'Forces nc to use IPv6 addresses only.')
    D_Option = forms.BooleanField(
        required = False,
        label = '-D',
        help_text = 'Enable debugging on the socket.')
    dOption = forms.BooleanField(
        required = False,
        label = '-d',
        help_text = 'Do not attempt to read from stdin.')
    hOption = forms.BooleanField(
        required = False,
        label = '-h',
        help_text = 'Prints out nc help.')
    kOption = forms.BooleanField(
        required = False,
        label = '-k',
        help_text = 'Forces nc to stay listening for another connection after its current connection is completed. It is an error to use this option without the -l option.')
    lOption = forms.BooleanField(
        required = False,
        label = '-l',
        help_text = 'Used to specify that nc should listen for an incoming connection rather than initiate a connection to a remote host. It is an error to use this option in conjunction with the -p , -s , or -z options. Additionally, any timeouts specified with the -w option are ignored.')
    nOption = forms.BooleanField(
        required = False,
        label = '-n',
        help_text = 'Do not do any DNS or service lookups on any specified addresses, hostnames or ports.')
    rOption = forms.BooleanField(
        required = False,
        label = '-r',
        help_text = 'Specifies that source and/or destination ports should be chosen randomly instead of sequentially within a range or in the order that the system assigns them.')
    S_Option = forms.BooleanField(
        required = False,
        label = '-S',
        help_text = 'Enables the RFC 2385 TCP MD5 signature option.')
    tOption = forms.BooleanField(
        required = False,
        label = '-t',
        help_text = 'Causes nc to send RFC 854 DON\'T and WON\'T responses to RFC 854 DO and WILL requests. This makes it possible to use nc to script telnet sessions.')
    U_Option = forms.BooleanField(
        required = False,
        label = '-U',
        help_text = 'Specifies to use Unix Domain Sockets.')
    uOption = forms.BooleanField(
        required = False,
        label = '-u',
        help_text = 'Use UDP instead of the default option of TCP.')
    vOption = forms.BooleanField(
        required = False,
        label = '-v',
        help_text = 'Have nc give more verbose output.')
    zOption = forms.BooleanField(
        required = False,
        label = '-z',
        help_text = 'Specifies that nc should just scan for listening daemons, without sending any data to them. It is an error to use this option in conjunction with the -l option.')
